home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
A.C.E. 2
/
ACE CD 2.iso
/
FILES
/
UTILS
/
AMOS3.DMS
/
AMOS3.adf
/
Instr_Conv.AMOS
/
Instr_Conv.amosSourceCode
Wrap
AMOS Source Code
|
1978-10-10
|
8KB
|
320 lines
'---------------------------------------------------------------------------
' SoundTracker to IFF instrument converter
'
' By Francois Lionet
'
' (c) Mandarin/Jawx 1990
'---------------------------------------------------------------------------
' This program allows you to transform any instrument referenced by
' SoundTracker's preset list (version 2.3 and above), into an IFF 8SVX
' instrument.
' It is neccessary to do this because the Sonix to AMOS converter can only
' accept single IFF samples.
'---------------------------------------------------------------------------
Dim FR(7)
FR(1)=65 : FR(2)=131 : FR(3)=262 : FR(4)=523 : FR(5)=1046 : FR(6)=2093 : FR(7)=4186
'
Global FR(),OCT,LSAM,ADSAM,ADRAW,FREQ,L1,L2,AD2,VOL,NAME$
'
' Open an ice-cream (sorry a nice screen) with a rainbow
Screen Open 0,640,200,2,Hires : Curs Off
Palette $0,$FC7
Set Rainbow 0,0,64,"","","(2,1,8)(2,-1,8)"
Rainbow 0,0,35,256
Channel 0 To Rainbow 0
Amal 0,"L: For R0=0 To 63; Let X=R0; For R1=0 To 4; Next R1; Next R0; Jump L"
Amal On
'
Wind Open 2,0,20*8,80,5 : Curs Off : Scroll Off
'
' Loads preset list
ALERT[">>> Loading preset list <<<"]
Open In 1,"St-00:PLST" : LPLST=Lof(1) : Close
Reserve As Work 10,LPLST
Bload "St-00:PLST",10
LPLST=Length(10)
APLST=Start(10)+$1E
NED=LPLST/$1E-2
ALERT[""]
'
' Open window (routines taken from CONFIG.AMOS!)
Window 0
LED=Min(NED,16)
Reserve Zone 50 : DR_MENU
Wind Open 1,24*8,8*(10-(LED+2)/2),32,LED+2,1 : Scroll Off
PY=0 : ACT=0 : Gosub ALL_PRINT
'
' Test for mouse
Do
ALERT[""] : If NAME$<>"" : ALERT["Loaded sample : "+NAME$] : End If
Window 1
Repeat
Z=Mouse Zone
If Z<>ACT
If ACT>0 : N=ACT : ACT=0 : Gosub ST_PRINT : End If
If Z>0 and Z<=LED : ACT=Z : N=Z : Gosub ST_PRINT : End If
End If
MK=Mouse Key
If MK and Z>LED
Exit If Z=26,2
Exit If Z=23 or Z=24
If LED<>NED
If Z=25 and PY>0
Home : Vscroll 1
Dec PY : N=1 : Gosub ST_PRINT
End If
If Z=28 and PY-LED>0
Add PY,-LED : Gosub ALL_PRINT
End If
If Z=27 and PY+LED<NED
Locate 0,LED-1 : Vscroll 3
Inc PY : N=LED : Gosub ST_PRINT
End If
If Z=29 and PY+LED*2<NED
Add PY,LED : Gosub ALL_PRINT
End If
End If
MK=0
End If
Until MK
While Mouse Key : Wend
'
' Load the sample
LD_IT:
If Z<=LED and Z<>0
ALERT["... Loading "+NM$+"..."]
LD_SAMP[NM$] : OLDNM$=NM$ : EXTRACT_NAME[NM$]
If Param
NAME$="" : ALERT[">>> Load aborted! <<<"] : Bell : Wait 50
Else
PL_SAMP
End If
End If
If Z=23
If NAME$<>""
PL_SAMP
Else
Bell : ALERT["Load a sample first!"] : Wait 50
End If
End If
If Z=24
If NAME$<>""
N$=PATH_OUT$+NAME$+"(IFF).Instr"
ALERT["---> Save as "+N$+"? (Y/N) <---"]
Repeat
Repeat : A$=Upper$(Inkey$) : Until A$<>""
Until(A$="Y") or(A$="N")
If A$="N"
N$=Fsel$("*.Instr",NAME$+"(IFF).Instr","Please choose new name","or change the disc.")
End If
If N$<>""
CONV_SAMP[N$]
If Param
ALERT[">>> Disc error! <<<"]
End If
Else
Bell : ALERT["Not done!"] : Wait 50
End If
Else
Bell : ALERT["Load a sample first!"] : Wait 50
End If
End If
While Mouse Key : Wend
Loop
'
' Back to basic
Screen Close 0
Edit
'-------------------
' Print ALL strings
'-------------------
ALL_PRINT:
For N=1 To LED
Gosub ST_PRINT
Set Zone N,X Graphic(0),Y Graphic(N-1) To X Graphic(28),Y Graphic(N-1)+8
Next
Return
'------------------
' Print ONE string
'------------------
ST_PRINT:
Curs Off
If N=ACT
Inverse On
Else
Inverse Off
End If
ADSAM=APLST+(PY+N)*$1E : NM$=""
X=0
Do
P=Peek(ADSAM+X) : Inc X
Exit If P=0
NM$=NM$+Chr$(P)
Loop
Locate 0,N-1 : Print Chr$(7); Using "###";N+PY;" : ";NM$;
Return
'
Procedure LD_SAMP[N$]
On Error Goto SAM_ERR
Open In 1,N$ : LSAM=Lof(1) : Close
Erase 5 : Reserve As Chip Work 5,LSAM+24
AD=Start(5)
A$="Samples " : Loke AD-8,Leek(Varptr(A$)) : Loke AD-4,Leek(Varptr(A$)+4)
Doke AD,1 : Add AD,2
Loke AD,6 : Add AD,4
Add AD,8
FREQ=8363 : Doke AD,FREQ : Add AD,2
Loke AD,LSAM : Add AD,4
ADRAW=AD : Bload N$,AD
L1=Deek(ADSAM+$16)*2 : L2=Deek(ADSAM+$1C)*2 : If L2=2 : L2=0 : End If
AD2=Deek(ADSAM+$1A)*2 : VOL=Deek(ADSAM+$18)
If L1+L2>LSAM : L1=LSAM-L2 : End If
Error 20
SAM_ERR: E=Errn : Close : Resume SAM_OUT
SAM_OUT:
End Proc[E-22]
Procedure PL_SAMP
ER_MENU
FREQ=8363 : OCT=4
Window 2 : Clw : Print At(1,1)+Border$(At(79,3),4);
For O=1 To 6
Print At(O*4+4,2)+Border$(Zone$("C"+Mid$(Str$(O+1),2),30+O),1);
Next O
Print At(32,2)+Border$(Zone$("Hear",37),1)
Print At(72,2)+Border$(Zone$("Quit",38),1)
For P=0 To 4
Print At(38+P,1)+Zone$("+",40+P*2);
Print At(38+P,3)+Zone$("-",41+P*2);
Next
Do
F$="00000" : A$=Str$(FREQ)-" "
Mid$(F$,6-Len(A$))=A$
Print At(38,2);F$
Doke Start(5)+14,FREQ
Sam Play 15,1
Do
Print At(48,2);"Octave:";OCT
Wait 10
If MK=1 : While Mouse Key : Wend : End If
Repeat
Z=Mouse Zone
MK=Mouse Key
A$=Inkey$
If A$=" " : Z=30+OCT-1 : MK=1 : End If
Until Z>=30 and MK<>0
If Z=37
Sam Play 15,1
End If
If Z=38
Exit 2
End If
If Z<37
Bell 1+12*(Z-30)
OCT=Z-30+1
End If
If Z>=40
ZZ=(Z-40)/2
A$=Mid$(F$,ZZ+1,1)
If Btst(0,Z)=0
A$=Chr$(Asc(A$)+1)
If A$>"9" : A$="0" : End If
Else
A$=Chr$(Asc(A$)-1)
If A$<"0" : A$="9" : End If
End If
Mid$(F$,ZZ+1)=A$
FREQ=Val(F$)
Exit 1
End If
Loop
Loop
DR_MENU
End Proc
Procedure CONV_SAMP[N$]
ALERT["...Saving "+N$+"..."]
On Error Goto CONV_ERR
Open Out 1,N$
Print #1,"FORM 8SVXVHDR";
OUT_NB[4,20]
OUT_NB[4,L1]
OUT_NB[4,L2]
OUT_NB[4,FREQ/FR(OCT)]
OUT_NB[2,FREQ]
OUT_NB[1,1]
OUT_NB[1,0]
OUT_NB[4,VOL*$400]
Print #1,"BODY";
OUT_NB[4,LSAM]
P1=LSAM/256 : P2=LSAM-P1*256 : A$=Space$(256)
If P1
For P=0 To P1-1
Copy ADRAW+P*256,ADRAW+P*256+256 To Varptr(A$)
Print #1,A$;
Next
End If
If P2
For P=0 To P2-1
A$=Chr$(Peek(ADRAW+P1*256+P))
Print #1,A$;
Next
End If
P=Pof(1)
If Btst(0,A) : Print #1,Chr$(0); : End If
Pof(1)=4
OUT_NB[4,Lof(1)-12]
Error 20
'
CONV_ERR: E=Errn : Close : Resume CONV_OUT
CONV_OUT:
End Proc[E-22]
Procedure DR_MENU
Window 0 : X=20
ARROW[X*8+4,6*8,20,6,4,25] : ARROW[X*8+4,14*8,20,-6,4,27]
ARROW[X*8+4,3*8,10,12,4,28] : ARROW[X*8+4,17*8,10,-12,4,29]
CASE[20*8+4,10*8,12,22,4,26] : VER_TEXT["Quit",20,8]
CASE[60*8+4,10*8,12,72,4,23] : VER_TEXT[" Hear sample ",60,2]
CASE[66*8+4,10*8,12,72,4,24] : VER_TEXT["Save IFF sample",66,2]
End Proc
Procedure ER_MENU
Cls 0,0,0 To 24*8,160
Cls 0,58*8,0 To 640,160
End Proc
Procedure OUT_NB[BITS,NB]
For N=4-BITS To 3
A$=Chr$(Peek(Varptr(NB)+N)) : Print #1,A$;
Next
End Proc
Procedure ALERT[A$]
Window 2 : Clw
Centre At(,2)+A$
End Proc
Procedure ARROW[X,Y,SX,SY,S,ZON]
Set Paint 0
Ink 1 : Set Paint 3
For N=0 To S-1
Polyline X-SX+N,Y+SY To X,Y-SY To X+SX-N,Y+SY
Next
SX=Abs(SX) : SY=Abs(SY)
Set Zone ZON,X-SX,Y-SY To X+SX,Y+SY
End Proc
Procedure CASE[X,Y,SX,SY,S,ZON]
Set Paint 0
Ink 1 : Set Paint 3
For N=0 To S-1
Box X-SX+N,Y-SY+N To X+SX-N,Y+SY-N
Next
Set Zone ZON,X-SX,Y-SY To X+SX,Y+SY
End Proc
Procedure VER_TEXT[A$,X,Y]
For N=1 To Len(A$)
Locate X,Y+N-1
Print Mid$(A$,N,1);
Next
End Proc
Procedure EXTRACT_NAME[N$]
For N=Len(N$) To 1 Step -1
A$=Mid$(N$,N,1)
Exit If(A$=":") or(A$="/")
Next
NAME$=Mid$(N$,N+1)
End Proc